﻿<!--#include file="const.asp"-->
<%
'====================================================================
' 感谢使用晴天3G智能建站系统..
' 作者:梁永强.QQ:766750857
' 官方网址:wap.qt3g.com
' 声明:软件版权归作者所有,没有经过作者本人同意不得非法破解和传播本程序
'====================================================================
%>


<%
if sid="Null" then
	Response.Redirect "login.asp"
	Response.end
end if
IF  Request.QueryString("Action")="save" Then
	call savea
else
	call index
end if
end Function

Function index
	dim rs,sql,Runtxt,str,i,id,rst,sqlt,tp
	Runtxt=qingtian.RunStr
	dim fleg
    		fleg = Request("fleg")    
    		If fleg = "" Then fleg = 0
   		If Not IsNumeric(fleg) Then fleg = 0
    		fleg = CLng(fleg)
    		If fleg < 0 Then fleg = 0
dim page
    		Page = Request("page")      '当前页数
    		If Page = "" Then Page = 1
   		If Not IsNumeric(Page) Then Page = 1
    		Page = CLng(Page)
    		If Page < 1 Then Page = 1
    		id = Request("id")    
    		If id = "" Then id = 0
   		If Not IsNumeric(id) Then id = 0
    		id = CLng(id)
    		If id < 0 Then id = 0

	select case Request.QueryString("act")
	case "0"
		str="主"
	case "3"
		str="标签"
	case "4"
		str="图片"
	case "5"
		str="论坛分类"
	end select
			set rst=server.CreateObject("adodb.recordset")
			sqlt="select top 1 * from qingtian_bbsclass where id="&id
			rst.open sqlt,conn,1,1
			if not (rst.bof and rst.eof) then
if Request.QueryString("tp")="" then
tp=rst("img")
else
tp=Request.QueryString("tp")
end if
%>
	<card title="修改<%=str%>栏目"><p align="left">
<%if Request.QueryString("Act")<>5 then%>
	栏目名称：<%if Request.QueryString("Act")=3 or Request.QueryString("Act")=4 then%>(后台显示)<%end if%><br/>
	<input emptyok="true"  name="name<%=Runtxt%>" maxlength="50" value="<%=qingtian.FormatEdit(rst("name"))%>" type="text"/><br/>
<%else%>
	论坛分类名称：<br/>
<%
		Set Rs = Server.CreateObject("Adodb.Recordset")
		Sql = "SELECT * from qingtian_bbs where del=0 order by pid asc"
		Rs.Open Sql,conn,1,1
		if not (rs.bof and rs.eof)  then
		For i=1 to  rs.RecordCount
		If Rs.Eof Then
			exit For
		End If
		if i=1 then
		%>
		<select name="img<%=Runtxt%>" value="<%=rst("img")%>">
		<%
		end if
		%>
		<option value="<%=rs("id")%>"><%=qingtian.FormatEdit(rs("name"))%></option>
		<%
	  Rs.MoveNext
	  Next
	else	
	%>
	<select name="img<%=Runtxt%>" value="<%=rst("img")%>">
	<%
	  end if
	  Rs.close
	  set rs=nothing
	%>
	</select><br/>
	<%end if%>
	栏目排序：<br/>
	<input emptyok="true"  name="px<%=Runtxt%>" format="*N" value="<%=rst("pid")%>" type="text"/><br/>
	<%if  Request.QueryString("Act")="4" then%>
	图片地址：<a href='wenjian.asp?url=editbbsclass.asp?Act=<%=Request.QueryString("Act")%>@Page=<%=Page%>@fleg=<%=fleg%>@id=<%=id%>&amp;sid=<%=sid%>'>上传图片</a><br/>
	<input emptyok="true"  name="img<%=Runtxt%>" maxlength="255"  value="<%=tp%>" type="text"/><br/>
	<%end if%>
	<%if Request.QueryString("Act")="4" then%>
	联接地址(可留空)：<br/>
	<input emptyok="true"  name="urls<%=Runtxt%>" maxlength="255"  value="<%=rst("urls")%>" type="text"/><br/>
	<%end if%>
	<%if Request.QueryString("Act")="3" then%>
	<%=str%>内容：<br/>
	<input emptyok="true"  name="title<%=Runtxt%>"  value="<%=qingtian.FormatEdit(rst("content"))%>" type="text"/><br/>
	<%end if%>
	栏目换行:<br/>
	<select name="br<%=Runtxt%>" value="<%=rst("br")%>">
	<option value="1">栏目后自动换行</option>
	<option value="0">栏目后不换行</option>
	</select><br/>
	<%if Request.QueryString("Act")=0 then%>
	金币购买：
   	<select name="vip<%=Runtxt%>" value="<%=rst("vip")%>">
	<option value="0">否</option>
	<option value="1">是</option>
	</select><br/>
	购买金币：<br/>
	<input emptyok="true"  name="zf<%=Runtxt%>"  value="<%=rst("zf")%>" type="text"/><br/>
	VIP会员查看：
   	<select name="viphy<%=Runtxt%>" value="<%=rst("viphy")%>">
	<option value="0">否</option>
	<option value="1">是</option>
	</select><br/>
	<%end if%>
	隐藏：
   	<select name="yinz<%=Runtxt%>" value="<%=rst("yinz")%>">
	<option value="0">否</option>
	<option value="1">是</option>
	</select><br/>
	<anchor>确定提交
    	<go href="editbbsclass.asp?Action=save&amp;act=<%=Request.QueryString("Act")%>&amp;page=<%=page%>&amp;fleg=<%=fleg%>&amp;id=<%=id%>&amp;sid=<%=sid%>" method='post'>
        <postfield name="name" value="$(name<%=Runtxt%>)"/>
        <postfield name="px" value="$(px<%=Runtxt%>)"/>
        <postfield name="br" value="$(br<%=Runtxt%>)"/>
        <postfield name="urls" value="$(urls<%=Runtxt%>)"/>
        <postfield name="img" value="$(img<%=Runtxt%>)"/>
        <postfield name="title" value="$(title<%=Runtxt%>)"/>
        <postfield name="viphy" value="$(viphy<%=Runtxt%>)"/>
        <postfield name="vip" value="$(vip<%=Runtxt%>)"/>
        <postfield name="zf" value="$(zf<%=Runtxt%>)"/>
        <postfield name="yinz" value="$(yinz<%=Runtxt%>)"/>
    	</go>
	</anchor><br/>
<%
         else
%>
暂无栏目！
<%
         end if
	  Rst.close
	  set rst=nothing
%>

<a href='lbbsclass.asp?page=<%=page%>&amp;fleg=<%=fleg%>&amp;sid=<%=sid%>'>返回栏目管理</a><br/>
<a href='index.asp?sid=<%=sid%>'>后台管理首页</a><br/>
<%
end Function 


Function savea
	dim id,vip,zf,viphy,fleg
    		id = Request("id")    
    		If id = "" Then id = 0
   		If Not IsNumeric(id) Then id = 0
    		id = CLng(id)
    		If id < 0 Then id = 0
    		fleg = Request("fleg")    
    		If fleg = "" Then fleg = 0
   		If Not IsNumeric(fleg) Then fleg = 0
    		fleg = CLng(fleg)
    		If fleg < 0 Then fleg = 0

dim page
    		Page = Request("page")      '当前页数
    		If Page = "" Then Page = 1
   		If Not IsNumeric(Page) Then Page = 1
    		Page = CLng(Page)
    		If Page < 1 Then Page = 1

		dim name,br,title,px,urls,img,rs,sql,errs,yinz
		name=Request.form("name")
		px=Request.form("px")
		urls=Request.form("urls")
		img=Request.form("img")
		br=Request.form("br")
		title=Request.form("title")
    	    	vip=Request.form("vip")
	        zf=Request.form("zf")
	        yinz=Request.form("yinz")
 		viphy=TRim(Request.Form("viphy"))


		errs=""
		if Request.QueryString("act")<>"5" and name="" then errs=errs & "栏目名称不能为空<br/>"
		if px="" then errs=errs & "栏目排序不能为空<br/>"
		if br="" then errs=errs & "栏目换行不能为空<br/>"
		if Not IsNumeric(px) then errs=errs & "栏目排序必需为数字<br/>"
		if Not IsNumeric(br) then errs=errs & "栏目换行必需为数字<br/>"
		if Request.QueryString("act")="3" and title="" then errs=errs & "内容不能为空<br/>"
		if Request.QueryString("act")="4" and img="" then errs=errs & "图片地址不能为空<br/>"

		if Request.QueryString("act")=5 then
                name=conn.execute("SELECT name from qingtian_bbs where id="&img&"")("name")
                end if
		if Request.QueryString("act")=0 then
			if vip=""  then errs=errs&"VIP不能为空<br/>"
			if not isnumeric(vip) then errs=errs&"VIP必须为数字<br/>"
			if zf=""  then errs=errs&"金币不能为空<br/>"
			if not isnumeric(zf) then errs=errs&"金币必须为数字<br/>"
			if viphy=""  then errs=errs&"VIP会员查看不能为空<br/>"
			if not isnumeric(viphy) then errs=errs&"VIP会员查看必须为数字<br/>"
		end if

	IF len(errs)=0 then


		set rs=Server.CreateObject("ADODB.Recordset")
		Sql = "select top 1 * FROM qingtian_bbsclass where id="&id
		rs.open sql,conn,1,3
			rs("name")=name
			rs("pid")=px
			rs("br")=br
			rs("urls")=urls
			rs("img")=img
			rs("ext")=Request.QueryString("act")
			rs("content")=title
			rs("yinz")=yinz
		if Request.QueryString("act")=0 then
			rs("zf")=zf
			rs("vip")=vip
			rs("viphy")=viphy
		end if

		rs.update()

		rs.Close
		Set rs = Nothing
	%>
<card title="修改栏目"><p align="left">
		修改栏目成功!<br/><%

	else%>

	<card title="修改栏目"><p align="left">
		<%=errs%>
		<a href="editbbsclass.asp?act=<%=Request.QueryString("Act")%>&amp;page=<%=page%>&amp;id=<%=id%>&amp;fleg=<%=fleg%>&amp;sid=<%=sid%>">返回修改</a><br/>
<%	end if
%>
<a href='editbbsclass.asp?act=<%=Request.QueryString("Act")%>&amp;page=<%=page%>&amp;id=<%=id%>&amp;fleg=<%=fleg%>&amp;sid=<%=sid%>'>返回修改栏目</a><br/>
<a href='lbbsclass.asp?page=<%=page%>&amp;fleg=<%=fleg%>&amp;sid=<%=sid%>'>返回栏目管理</a><br/>
<a href='index.asp?sid=<%=sid%>'>后台管理首页</a><br/>
<%
end Function


%>
